﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary
{
    /// <summary>
    /// This class provides a scale matrix for two dimensional vectors.
    /// </summary>
    [Serializable]
    public class ScaleMatrix2D
    {
        /// <summary>
        /// The scale factor for the x axis.
        /// </summary>
        private readonly double scaleFactorX;

        /// <summary>
        /// The scale factor for the y axis.
        /// </summary>
        private readonly double scaleFactorY;

        /// <summary>
        /// Initializes a new instance of the <see cref="ScaleMatrix2D"/> class.
        /// </summary>
        /// <param name="scaleFactor">The scale factor for the x, y and z axis.</param>
        public ScaleMatrix2D(double scaleFactor)
        {
            this.scaleFactorX = scaleFactor;
            this.scaleFactorY = scaleFactor;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ScaleMatrix2D"/> class.
        /// </summary>
        /// <param name="scaleFactorX">The scale factor for the x axis.</param>
        /// <param name="scaleFactorY">The scale factor for the y axis.</param>
        public ScaleMatrix2D(double scaleFactorX, double scaleFactorY)
        {
            this.scaleFactorX = scaleFactorX;
            this.scaleFactorY = scaleFactorY;
        }

        /// <summary>
        /// Gets the scale matrix for the transformation.
        /// </summary>
        /// <returns>The scale matrix for the transformation.</returns>
        public Matrix GetScaleMatrix()
        {
            double[,] matrixData = new double[2,2];

            matrixData[0, 0] = this.scaleFactorX;
            matrixData[0, 1] = 0;

            matrixData[1, 0] = 0;
            matrixData[1, 1] = this.scaleFactorY;

            return new Matrix(matrixData);
        }
    }
}